const state = () => ({
  userInfo: JSON.parse(window.localStorage.getItem("userInfo")),
  token: window.localStorage.getItem("token"),
})
const getters = {
  userInfo: (state) => state.userInfo,
  token: (state) => state.token,
}
const mutations = {
  setUserInfo (state, data) {
    state.userInfo = data
  },
  setToken (state, data) {
    state.token = data
  }
}
const actions = {
  setUser ({ commit }, data) {
    commit('setUserInfo', data)
    window.localStorage.setItem("userInfo", JSON.stringify(data))
  },
  setToken ({ commit }, data) {
    commit('setToken', data)
    window.localStorage.setItem('token', data)
    window.sessionStorage.setItem('hawk_token', data)
  }
}
export default { state, getters, mutations, actions }